package o;

import com.huawei.hmf.annotation.NamedMethod;
import com.huawei.hmf.orb.exception.InvocationException;
import com.huawei.hwCloudJs.d.d;
import java.lang.reflect.Method;
import o.fhe.b;

public class ffe {
    private static final Object[] ˎ = new Object[0];
    private long ˊ = -1;
    private ffb ˋ;

    public ffe(ffb o_ffb) {
        this.ˋ = o_ffb;
    }

    protected void ˏ(long j) {
        this.ˊ = j;
    }

    protected Object ˊ(String str, String str2, fia o_fia, Object... objArr) {
        Class ˊ;
        fhc o_fhc;
        if (o_fia != null) {
            ˊ = o_fia.ˊ();
            if (ˊ != null) {
                fhb ˏ = fhh.ˏ(ˊ);
                if (ˏ != null) {
                    return ˏ.ˋ(this.ˋ, this.ˋ.ॱ(str, str2, ˏ(objArr)), o_fia);
                }
            }
        }
        ˊ = o_fia != null ? o_fia.ˊ() : null;
        fhc o_fhc2 = fhc.CLASS;
        if (ˊ != null && ˊ.isInterface()) {
            for (Method annotation : ˊ.getMethods()) {
                if (annotation.getAnnotation(NamedMethod.class) != null) {
                    o_fhc = fhc.NamedClass;
                    break;
                }
            }
        }
        o_fhc = o_fhc2;
        b ˎ = this.ˋ.ˎ(str, str2, o_fhc, ˏ(objArr));
        if (o_fia == null) {
            return null;
        }
        if (ˎ == null) {
            throw new InvocationException("Unexpected null value returned.");
        } else if (!ˎ.isSuccessful()) {
            throw new InvocationException("Invoke failed, error code " + (ˎ.ret == null ? d.b : ˎ.ret.cast(Integer.TYPE)));
        } else if (o_fhc != fhc.NamedClass) {
            return ˎ.ret.cast(o_fia.ॱ());
        } else {
            return fga.ॱ(this.ˋ, new Class[]{o_fia.ˊ()}, Long.valueOf(((Long) ˎ.ret.cast(Long.class)).longValue()));
        }
    }

    private Object[] ˏ(Object[] objArr) {
        if (objArr == null) {
            objArr = ˎ;
        }
        Object obj = new Object[(objArr.length + 1)];
        obj[0] = Long.valueOf(this.ˊ);
        if (objArr.length > 0) {
            System.arraycopy(objArr, 0, obj, 1, objArr.length);
        }
        return obj;
    }
}
